"""
@file: orders.py
@author: yangsiting
@data: 2021/04/24
@desc:
"""
from .base import db
from libs.enums import MethodType
from werkzeug.security import generate_password_hash

# 订单信息表
# 订单个人信息

class Order_Info(db.Model):
    __tablename__ = "order_info"
    order_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    user_profile_id = db.Column(db.ForeignKey('user_profile.user_profile_id'))
    goods_id = db.Column(db.Integer)
    goods_num = db.Column(db.Integer)
    goods_price = db.Column(db.Float)
    total_prices = db.Column(db.Integer)

    @classmethod
    def create_info(cls, user_profile_id, goods_id, goods_num,goods_price,total_prices):
        info = cls()
        info.user_profile_id = user_profile_id
        info.goods_id = goods_id
        info.goods_num = goods_num
        info.goods_price = goods_price
        info.total_prices = total_prices
        db.session.add(info)
        db.session.commit()

class Order_User_Info(db.Model):
    __tablename__ = "order_userinfo"
    id = db.Column(db.Integer,primary_key=True,autoincrement=True)
    user_profile_id = db.Column(db.ForeignKey('user_profile.user_profile_id'))
    user_name = db.Column(db.String(255))
    user_phone = db.Column(db.String(20))
    user_addr = db.Column(db.String(255))

    @classmethod
    def create_user(cls, user_profile_id, user_name, user_phone,user_addr):
        info = cls()
        info.user_profile_id = user_profile_id
        info.user_name = user_name
        info.user_phone = user_phone
        info.user_addr = user_addr
        db.session.add(info)
        db.session.commit()




